﻿using UnityEngine;
using System.Collections;
using System;

public class Area : IArea
{
    Group _GroupA;
    Group _GroupB;

    public Area()
    {
        _GroupA = new Group();
        _GroupB = new Group();
    }

    FactionType _RoundFactionType = FactionType.Null;

    /// <summary>
    /// 战斗开始
    /// </summary>
    public void Enter()
    {
        _GroupA.Enter();
        _GroupB.Enter();

        //for (int i = 0; i < BattleManager.Instance.targets.Length; ++i)
        //{
        //    BattleManager.Instance.targets[i].Enter();
        //}
    }

    void BattleRound()
    {

        ResetRound();

        ReOrderRound();

    }

    public void Quit()
    {
    }

    /// <summary>
    /// 重置一个回合
    /// </summary>
    public void ResetRound()
    {
        _GroupA.Reset();
        _GroupB.Reset();
        switch (_RoundFactionType)
        {
            case FactionType.Left:
                _RoundFactionType = FactionType.Right;
                break;
            case FactionType.Null:
            case FactionType.Right:
                _RoundFactionType = FactionType.Left;
                break;
        }
    }

    public void ReOrderRound()
    {
        _RoundList.Clear();

        switch (_RoundFactionType)
        {
            case FactionType.Left:
                _RoundList.Add(BattleManager.Instance.targets[0]._Target);
                _RoundList.Add(BattleManager.Instance.targets[1]._Target);
                break;
            case FactionType.Right:
                _RoundList.Add(BattleManager.Instance.targets[2]._Target);
                _RoundList.Add(BattleManager.Instance.targets[3]._Target);
                _RoundList.Add(BattleManager.Instance.targets[4]._Target);
                break;
        }
    }

    /// <summary>
    /// 当前回合的队列
    /// </summary>
    TargetList _RoundList = new TargetList();

    /// <summary>
    /// 加入队列
    /// </summary>
    public void Quene(Targetable target)
    {
        _RoundList.Add(target._Target);
    }

    public void Reset()
    {
    }
}
